<?php get_header() ?>
<?php 
$catslideshow = 2; 
?>
<div class="main">
    <div class="slide-home">
        <div class="container">
            <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
              <!-- Wrapper for slides -->
              <div class="carousel-inner">
                <?php
                    wp_reset_query(); $k = 0 ; 
                    query_posts(array('cat' => $catslideshow));
                    while (have_posts()): the_post();
                        ?>
                        <div class="item <?php echo !$k++ ? 'active' : ''  ?>">
                            <a href="<?php the_permalink() ?>">
                                <?php the_post_thumbnail(array(980, 432), array('class' => 'img-thumbnail')) ?>
                            </a>
                            <div class="subdesc">
                                <h2><?php the_title() ?></h2>
                                <?php the_excerpt() ?>
                                <p class="viewmore"><a href="<?php the_permalink() ?>">Xem thêm</a></p>
                            </div>  
                        </div>
                    <?php endwhile; ?>
              </div>

              <!-- Controls -->
              <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
                <span class="glyphicon slide-left"></span>
              </a>
              <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
                <span class="glyphicon slide-right"></span>
              </a>
            </div>
        </div>
    </div>
    <div class="content-service">
        <div class="container">
            <div class="left service">
                <div class="breadcrumbs">
                 <?php wp_reset_query(); if(function_exists('bcn_display')){bcn_display();}?>
                </div>
                <div class="content">
                     <?php
                      wp_reset_query();
                      $posts_per_page = 12;
                      $page = (get_query_var('page')) ? get_query_var('page') : 1;
                      $cat = get_query_var('cat');
                      query_posts(array('cat' => $cat,'posts_per_page'=>$posts_per_page,'page' => $page, 'offset' => $posts_per_page*($page-1)));
                      while (have_posts()): the_post(); ?>
                        <article class="blog-post">                      
                          <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(array(140,120),array('style'=>'width:140px;height:120px;float:left;margin:5px;')); ?></a>
                          <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
                          <div class="entry-content">
                              <?php echo str_replace('[...]','...',strip_tags(get_the_excerpt())); ?>
                              <p class="more-link"><a href="<?php the_permalink() ?>">Xem thêm</a></p>
                          </div>                          
                          <div style="clear:both;"></div>
                        </article>
                     <?php endwhile; ?>
                     <?php
                      global $wp_query;
                      $pagination = paginate_links( array(
                          'current' =>  max( 1,get_query_var('page')),
                          'total' => $wp_query->max_num_pages,
                          'type' => 'array',
                          'next_text' => '»',
                          'prev_text' => '«'
                      ) );
                      ?>
                      <?php if(isset($pagination)){ 
                      $pagination = str_replace("href=''", "href='".get_category_link('')."?page=1'", $pagination);
                      $pagination = str_replace('href=""', 'href="'.get_category_link('').'?page=1"', $pagination);
                      ?>
                      <nav class="inner wp-pagination">
                          <div class="pagination">
                              <ul class="page-numbers" style="margin-left: -40px;">
                                <li><b style="color:black;">Page: </b></li>
                              <?php $i=0; foreach($pagination as $page){ ?>
                                  <li>
                                      <?php echo $page; ?>
                                  </li>
                              <?php } ?>
                              </ul>
                          </div>
                      </nav>
                      <?php } ?>
                </div>
            </div>
            <div class="right">
                <?php get_sidebar() ?>
            </div>
        </div>
    </div>
</div>

<?php get_footer() ?>

